package com.bytecub.simulate.device.instance;

import com.bytecub.common.domain.dto.response.prop.TemplateResDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;

/**
  * ByteCub.cn.
  * Copyright (c) 2020-2021 All Rights Reserved.
  * 
  * @author bytecub@163.com  songbin
  * @version Id: ReporterService.java, v 0.1 2021-02-20  Exp $$
  */
@EnableAsync
@Service
@Slf4j
public class ReporterService {

    @Async
    public void execute(DeviceInstance deviceInstance){
        while(true){
            this.report(deviceInstance);
        }
    }

    private void report(DeviceInstance deviceInstance){
        try{
            deviceInstance.reportData();
            Thread.sleep(1000*60);
        }catch (Exception e){
            log.warn("异常", e);
        }
    }
}
